import Vue from 'vue'
import VueRouter from 'vue-router'

// 组件通过export暴露接口，路由中导入组件
import Auth from '@/views/Auth.vue'
import Home from '@/views/Home.vue'

// 导入 vue-router 依赖
Vue.use(VueRouter)

export default new VueRouter({
  routes: [
    {
      path: '/auth', // 跳转路径
      name: 'auth', // 名称
      component: Auth, // 组件
    },
    {
      path: '/login', // 跳转路径
      name: 'login', // 名称
      component: Auth, // 组件
    },
    {
      path: '/register', // 跳转路径
      name: 'register', // 名称
      component: Auth, // 组件
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
    },
    {
      path: '/education',
      name: 'courseList',
      component: () => import('@/views/educational/education.vue'),
      redirect: '/education/course',
      children: [
        {
          path: '/education/course',
          name: 'education-course',
          component: () => import('@/views/educational/education-course.vue'),
        },
        {
          path: '/education/home',
          name: 'education-home',
          component: () => import('@/views/educational/education-home.vue'),
        },
        {
          path: '/education/teachering',
          name: 'education-teachering',
          component: () =>
            import('@/views/educational/education-teachering.vue'),
        },
        {
          path: '/education/finance',
          name: 'education-finance',
          component: () => import('@/views/educational/education-finance.vue'),
        },
        {
          path: '/education/add/:courseFormat',
          name: 'education-add',
          component: () =>
            import('@/views/educational/education-course-add.vue'),
        },
      ],
    },
    {
      path: '/',
      redirect: '/home',
    },
    {
      path: '*',
      redirect: '/',
    },
  ],
})
